local yuxing = fk.CreateSkill {
  name = "lvshi__yuxing",
  tags = { "Turn" }
}

Fk:loadTranslationTable{
  ["lvshi__yuxing"] = "聿兴",
  [":lvshi__yuxing"] = "当你使用此回合未使用过的基本牌后，你可将一张手牌当【卷】使用，若此牌点数大于使用的牌，你发现的牌名+2，若你发现了与使用牌名称相同的牌，你摸一张牌。",
  ["#ls__yuxing-askuse"] = "聿兴：你可将一张手牌当【卷】使用",

  ["$lvshi__yuxing1"] = "教化民智，唯仰兴学之功。",
  ["$lvshi__yuxing2"] = "学为国之柱，不可不兴。",
}

yuxing:addEffect(fk.CardUseFinished, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(yuxing.name) and target == player and data.card.type == Card.TypeBasic
    and not table.contains(player:getTableMark("yuxing-turn"), data.card.trueName)
  end,
  on_cost = function(self, event, target, player, data)
    local use = player.room:askToUseVirtualCard(player, {
      name = "scroll",
      skill_name = yuxing.name,
      prompt = "#ls__yuxing-askuse",
      cancelable = true,
      card_filter = {
        n = 1,
        cards = player:getHandlyIds(),
      },
      extra_data = {
        bypass_times = true,
      },
      skip = true,
    })
    if use then
      event:setCostData(self, {use = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addTableMark(player, "yuxing-turn", data.card.trueName)
    local use = event:getCostData(self).use
    use.extra_data = use.extra_data or {}
    if use.card.number > data.card.number then
      use.extra_data.additionalScroll = (use.extra_data.additionalScroll or 0) + 2
    end
    room:useCard(use)
    if use.extra_data.name == data.card.trueName then
      player:drawCards(1, yuxing.name)
    end
  end,
})

return yuxing
